extends CharacterBody2D

var SPEED:int = 1000
var can_move:bool = false
var target = null
# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	if can_move:
		velocity = global_position.direction_to(target.global_position) * SPEED
		move_and_slide()
	pass

func _on_area_2d_body_entered(body):
	if body.is_in_group("player"):
		can_move = true
		target = body
	pass # Replace with function body.
